package com.itlong.cloud.user.operate;

import com.itlong.cloud.POJO.DTO.operate.OperateFunctionGetPageDTO;
import com.itlong.cloud.POJO.PO.OperateFunctionPO;
import com.itlong.cloud.POJO.VO.operate.OperateAllotFunctionGetVO;
import com.itlong.cloud.POJO.VO.operate.OperateFunctionVO;
import com.itlong.cloud.POJO.VO.operate.OperateGetRoleMenuVO;
import com.itlong.cloud.utils.page.Page;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.util.List;

/**
 * <desc>
 *      运营-资源菜单业务处理暴露接口
 * </desc>
 *
 * @createDate 2017/09/21
 */
@FeignClient(name = "user-service")
public interface IOperateFunctionServiceClient {
    /**
     * <desc>
     *      获取分页列表
     * </desc>
     *
     * @param operateFunctionGetPageDTO 查询参数DTO
     * @return page模型
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/getPage")
    Page<OperateFunctionPO> getPage(@RequestBody OperateFunctionGetPageDTO operateFunctionGetPageDTO) throws Exception;

    /**
     * <desc>
     *      保存资源
     * </desc>
     *
     * @param operateFunctionPO 资源实体
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/save")
    Integer save(@RequestBody OperateFunctionPO operateFunctionPO) throws Exception;

    /**
     * <desc>
     *      更新资源
     * </desc>
     *
     * @param operateFunctionPO 资源实体
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/update")
    Integer update(@RequestBody OperateFunctionPO operateFunctionPO) throws Exception;

    /**
     * <desc>
     *      查询单条资源
     * </desc>
     *
     * @param operateFunctionPO 资源实体
     * @return 资源实体
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/getOne")
    OperateFunctionPO getOne(@RequestBody OperateFunctionPO operateFunctionPO);

    /**
     * <desc>
     *      删除资源
     * </desc>
     *
     * @param functionIds 资源id数组
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/delete")
    Integer delete(@RequestParam("functionIds")String functionIds);

    /**
     * <desc>
     *      获取子节点
     * </desc>
     *
     * @param functionId 资源id
     * @return 子级结果集
     * @author Jiaqi.X
     * @createDate 2017/09/21
     */
    @RequestMapping(path = "/operate/system/function/getChilds")
    List<OperateFunctionVO> getChilds(@RequestParam("functionId")String functionId);


    /**
     * <desc>
     *      获取分配菜单所有节点
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2017/09/26
     */
    @RequestMapping(path = "/operate/system/function/getAllotFunction")
    public List<OperateAllotFunctionGetVO> getAllotFunction(@RequestParam("roleId")String roleId);

    /**
     * <desc>
     *      获取当前节点的父级节点以及同级别所有父级节点
     * </desc>
     *
     * @param parent 资源id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/09/30
     */
    @RequestMapping(path = "/operate/system/function/getParentLevelFunctions")
    public List<OperateFunctionPO> getParentLevelFunctions(@RequestParam("parent")String parent);

    /**
     * <desc>
     *      获取用户角色的按钮权限
     * </desc>
     *
     * @param roleIds 角色id 多个,号分隔
     * @param functionId    当前点击菜单id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/10/17
     */
    @RequestMapping(path = "/operate/system/function/getAuthBtns")
    public List<OperateGetRoleMenuVO> getAuthBtns(@RequestParam("roleIds") String roleIds, @RequestParam("functionId") String functionId);

    /**
     * <desc>
     *      获取用户角色的菜单
     * </desc>
     *
     * @param roleIds 角色id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/10/17
     */
    @RequestMapping(path = "/operate/system/function/getRoleMenu")
    public List<OperateGetRoleMenuVO> getRoleMenu(@RequestParam("roleIds")String roleIds);

    /**
     * <desc>
     *      获取角色权限的所有资源并缓存至redis
     * </desc>
     *
     * @param roleIds 角色id 多个,号分隔
     * @return
     * @author Jiaqi.X
     * @createDate 2017/10/17
     */
    @RequestMapping(path = "/operate/system/function/getRoleAuthFunctions")
    public List<OperateFunctionPO> getRoleAuthFunctions(@RequestParam("roleIds")String roleIds,@RequestParam("token")String token) throws IOException;
}
